home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6638 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.8 KB

  1. Path: news.eden.com!usenet
  2. From: Shane Sadler <nexus@eden.com>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: c++ and readability
  5. Date: Wed, 14 Feb 1996 19:20:34 -0700
  6. Organization: Eden Matrix Services
  7. Message-ID: <31229872.2A980200@eden.com>
  8. References: <DMoyuG.CD4@world.std.com>
  9. NNTP-Posting-Host: net-3-030.austin.eden.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (X11; I; Linux 1.2.8 i586)
  14.  
  15. bender wrote:
  16. > Its disappointing to me that us C programmers haven't yet developed a
  17. > standard, readable style of writing code.
  18. > I find it almost impossible to read other peoples code, merely because of
  19. > their style of using tabs, spaces, and putting the { delimeter at the end
  20. > of the line.
  21. > (This is actually Java code, but its good enough to prove my point)
  22. > Now I ask you which is more readable, this:
  23. >         if (startImage > endimage) {
  24. >             for (int i = startImage; i >= endImage; i--) {
  25. >                 result.addElement(new URL(imageSource, "T"+i+".gif"));
  26. >             }
  27. >         } else if (sounds != null) {
  28. >                     badURL = fetchSounds(sounds);
  29. >                     if (badURL != null) {
  30. >                         loadError(badURL, soundLabel);
  31. >                         return;
  32. >                     }
  33. >                 }
  34. > This is chaos, how do you know
  35. > or this:
  36. >         if (startImage > endImage)
  37. >            {
  38. >            for (int i = startImage; i >= endImage; i--)
  39. >               {
  40. >               result.addElement(new URL(imageSource, "T"+i+".gif"));
  41. >               }
  42. >            }
  43. >         else if (sounds != null)
  44. >            {
  45. >            badURL = fetchSounds(sounds);
  46. >            if (badURL != null)
  47. >               {
  48. >               loadError(badURL, soundLabel);
  49. >               return;
  50. >               }
  51. >            }
  52. > Almost all code I see by other programmers is like the first example. Now
  53. > am I nuts, is it just me that thinks its hard to read?
  54.  
  55. Well, I can read both of them, but as far as preferences, I prefer the
  56. style I use....Why is that not surprising?....which is something in
  57. between your two examples. But that's just when I'm doing stuff at home.
  58. I think it would be irresponsible of me to use anything but the One True
  59. Brace Style (of K&R fame) for coding at work. It's readable and widely
  60. used and isn't it one of Henry Spencer's Ten Commmandments? I don't find
  61. OTBS as aesthetically pleasing (for whatever that's worth), but whoever
  62. ends up maintaining/fixing my code won't be taking my name in vain quite
  63. as much. Besides, while I haven't used one, aren't there C "beautifiers"
  64. out there that you can configure to your favorite style?
  65.  
  66. -- Shane
  67. ===================================================================
  68. S. M. Sadler
  69. e-mail: nexus@eden.com
  70. Web: http://www.eden.com/~nexus
  71.